import Vue from 'vue'
import Router from 'vue-router'
// import test from '@/components/test'

Vue.use(Router)

export default new Router({
  scrollBehavior(to, from, savePosition) { // 在点击浏览器的“前进/后退”，或者切换导航的时候触发。
    // console.log(to) // to：要进入的目标路由对象，到哪里去
    // console.log(from) // from：离开的路由对象，哪里来
    // console.log(savePosition) // savePosition：会记录滚动条的坐标，点击前进/后退的时候记录值{x:?,y:?}
    if (savePosition) {
      return savePosition
    } else {
      return {x: 0, y: 0}
    }
  },
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('@/components/home/home' /* webpackChunkName: 'home' */),
      meta: {
        showFooter: true
      }
    },
    {
      path: '/',
      name: 'test',
      component: () => import('@/components/test' /* webpackChunkName: 'test' */)
    },
    {
      path: '/shop',
      name: 'shop',
      component: () => import('@/components/shop/shop' /* webpackChunkName: 'shop' */),
      meta: {
        // showFooter: true
      },
      alias: '/c'
    },
    {
      path: '/shopCart',
      name: 'shopCart',
      component: () => import('@/components/shopCart/shopCart' /* webpackChunkName: 'shopCart' */),
      meta: {
        showFooter: true
      }
    },
    {
      path: '/my',
      name: 'my',
      component: () => import('@/components/my/my' /* webpackChunkName: 'my' */),
      meta: {
        showFooter: true
      }
    }
  ]
})
